
<?php include("header.php"); ?>

<script type="text/javascript">

function addQuestion() {
    window.location.href = "<?php echo SITE_URL;?>/?c=GetThePicture&a=addQuestion";
}

function addAnswer() {
    window.location.href = "<?php echo SITE_URL;?>/?c=GetThePicture&a=addAnswer";
}
</script>
	<div class="one_third">
		<div class="box_tool">
			<div class="box_head"><?php echo _LB_TOOLBOX; ?></div>

			<div class="box_content">
                            <a href="<?php echo SITE_URL."?c=GetThePicture&a=addQuestion"; ?>" onclick="addQuestion();">
                                <?php echo _LB_ADD_QUESTION; ?>
                            </a>
                            <br/>
                            <a href="<?php echo SITE_URL."?c=GetThePicture&a=addAnswer"; ?>" onclick="addAnswer();">
                                <?php echo _LB_ADD_ANSWER; ?>
                            </a>
			</div>
		</div>
		<div class="spacer"></div>
	</div>

	<div class="two_third" style="height:1%">
		<div class="box_two_third">
			<div class="box_head"><?php echo _LB_QUESTION_LIST; ?></div>
			<div class="box_content">
			<?php if($question->countRows()) { ?>
                            <?php $cur_question = 0; ?>
					<?php while($question->fetchNext()) { ?>
                                            <?php if ($question->question_id != $cur_question) { ?>
                                                <?php if ($cur_question != 0) { ?>
                                                    </table>
                                                    <div style="clear:both;"></div>
						</div>
					</div>
                                                <?php } ?>
                                        <div class="object">
						<div class="head">
							<div class="right remove_top">
								<a href="<?php echo SITE_URL;?>/?c=GetThePicture&a=editQuestion&id=<?php echo $question->question_id;?>">
									<img src="<?php echo SITE_URL;?>/images/<?php echo IMAGE_NAME_EDIT_SMALL;?>" title="<?php echo _LB_EDIT;?>" alt="<?php echo _LB_EDIT;?>"/>
								</a>
								<?php if($question->isDeleteAble($question->question_id)) {?>
									<a onclick="return confirm('<?php echo _MSG_DELETE_CONFIRM;?>');" href="<?php echo SITE_URL;?>/?c=GetThePicture&a=deleteQuestion&id=<?php echo $question->question_id;?>">
										<img src="<?php echo SITE_URL;?>/images/<?php echo IMAGE_NAME_DELETE_SMALL?>" title="<?php echo _LB_DELETE;?>" alt="<?php echo _LB_DELETE;?>"/>
									</a>
							  	<?php } else { ?>
									<img class="small" src="<?php echo SITE_URL;?>/images/delete_not_small.png"/>
								<?php } ?>
							</div>
							<b><?php echo $question->question_title;?></b>
						</div>
                                            
                                            <div class="content">
                                            <div class="thumbnail">
                                                <img src="<?php echo SITE_URL.'/../images/'.$question->image; ?>" alt="" width="133" height="100" />
                                            </div>    
                                                <?php } ?>
                                                <?php if ($question->question_id != $cur_question && $question->answer_id) { ?>
						
                                                    <table border="0" cellpadding="3" cellspacing="0" style="float:left;width:441px;margin:2px 0 0 10px;">
                                                        <?php } ?>
                                                        <?php if ($question->answer_id) { ?>
                                                        <tr>
                                                            <td width="80%">
                                                                <?php if ($question->answer_correct) { ?>
                                                                <b><?php echo $question->answer_content; ?></b>
                                                                <?php } else { ?>
                                                                <?php echo $question->answer_content; ?>
                                                                <?php } ?>
                                                            </td>
                                                            <td>
                                                                <?php if (!$question->answer_correct) { ?>
                                                                    <a href="<?php echo SITE_URL;?>/?c=GetThePicture&a=setCorrect&id=<?php echo $question->answer_id;?>&correct=1">
									<img src="<?php echo SITE_URL;?>/images/<?php echo IMAGE_NAME_STOP_SMALL;?>" title="<?php echo _LB_TURN_CORRECT;?>" alt="<?php echo _LB_TURN_CORRECT;?>"/>
                                                                    </a>
                                                                <?php } else { ?>
                                                                    <img src="<?php echo SITE_URL;?>/images/<?php echo IMAGE_NAME_RESUME_SMALL;?>" title="<?php echo _LB_CORRECTED;?>" alt="<?php echo _LB_CORRECTED;?>"/>
                                                                <?php } ?>
                                                                
                                                                <a href="<?php echo SITE_URL;?>/?c=GetThePicture&a=editAnswer&id=<?php echo $question->answer_id;?>">
									<img src="<?php echo SITE_URL;?>/images/<?php echo IMAGE_NAME_EDIT_SMALL;?>" title="<?php echo _LB_EDIT;?>" alt="<?php echo _LB_EDIT;?>"/>
								</a>
								<?php if($question->isAnswerDeleteAble($question->answer_id)) {?>
									<a onclick="return confirm('<?php echo _MSG_DELETE_CONFIRM;?>');" href="<?php echo SITE_URL;?>/?c=GetThePicture&a=deleteAnswer&id=<?php echo $question->answer_id;?>">
										<img src="<?php echo SITE_URL;?>/images/<?php echo IMAGE_NAME_DELETE_SMALL?>" title="<?php echo _LB_DELETE;?>" alt="<?php echo _LB_DELETE;?>"/>
									</a>
							  	<?php } else { ?>
									<img class="small" src="<?php echo SITE_URL;?>/images/delete_not_small.png"/>
								<?php } ?>
                                                            </td>
                                                        </tr>
                                                        <?php } ?>
								
                                              <?php $cur_question = $question->question_id; ?>      
					<?php } ?>
                                                        </table>
                                                <div style="clear:both;"></div>
						</div>
					</div>
			<?php } else { ?>
				<p><?php echo _MSG_NO_EXISTING_QUESTION;?></p>
			<?php } ?>
			</div>
		</div>
		
	</div>
<?php include("footer.php"); ?>
